package com.testdemo.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.widget.DividerItemDecoration;

import com.chad.library.adapter.base.BaseViewHolder;
import com.testdemo.R;
import com.testdemo.common.base.BaseListActivity;
import com.testdemo.common.utils.PageLoader;
import com.testdemo.ui.activity.bluetooth.BluetoothListActivity;

import java.util.ArrayList;

public class MainActivity extends BaseListActivity<MainActivity.Item> {

    class Item {
        String title;
        Class activityClass;

        public Item(String title, Class<? extends Activity> activityClass) {
            this.title = title;
            this.activityClass = activityClass;
        }

        void onClick(){
            startActivity(new Intent(mContext,activityClass));
        }
    }


    @Override
    public void initView() {

        mTitleBar.setTitleText("主界面");
        mTwinklingRefreshLayout.setEnableLoadmore(false);
        mTwinklingRefreshLayout.setEnableRefresh(false);

        getData(0,0,0);
    }


    @Override
    public void onItemClick(BaseViewHolder holper, Item item) {
        item.onClick();
    }

    @Override
    public int getItemLayoutId() {
        return R.layout.item_text;
    }

    @Override
    public void setItemData(BaseViewHolder holper, Item item) {
        holper.setText(R.id.tv_item,item.title+"");
    }

    @Override
    public void getData(int pageIndex, int pageSize, int getDataType) {

        ArrayList<Item> items = new ArrayList<>();
        items.add(new Item("蓝牙测试",BluetoothListActivity.class));


        mPageLoader.getDateFinish(items, PageLoader.TYPE_UPTATE);
    }


}
